package org.x.chatmod.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.x.chatmod.entity.ChatUser;
import org.x.chatmod.vo.FriendVO;

import org.x.chatmod.service.ChatFriendService;

import java.util.List;

@RestController
@RequestMapping("/api")
public class ChatAppController {
    @Autowired
    ChatFriendService friendService;
    //获取用户的好友列表及状态
    @GetMapping("/friend/list")
    public List<FriendVO> getFriendList(@RequestParam Long userId) {
        return friendService.getFriendList(userId);
    }

    //获取chatUser信息
    @GetMapping("/user/info")
    public ChatUser getFriendInfo(@RequestParam Long userId) {
        return friendService.getFriendInfo(userId);
    }
    //根据用户是否登录更新用户在线状态
    @GetMapping("/user/online")
    public ChatUser updateUserOnlineStatusByLogin(@RequestParam Long userId) {
        return friendService.updateUserOnlineStatusByLogin(userId);
    }
}
